<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ page isELIgnored="false" %>

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/custom-theme/jquery-ui.custom.min.css" />	
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
	<script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.form.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/json2.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/messages_zh.js"></script>
	<script type='text/javascript'>
        $(function(){
             $("#but1").button();
             $("#but2").button();
             load();
             loadFzData();
        });
        
        function save(){
    var parent=window.dialogArguments; 
    parent.document.getElementById("fazmc").value=$("#fazmc").val();
    parent.document.getElementById("fazbm").value=$("#fazid").val(); 
    parent.document.getElementById("xianzkmc1").value=$("#xianzkmc1").val();
    parent.document.getElementById("xianzkid1").value=$("#xianzkid1").val(); 
    parent.document.getElementById("xianzkmc2").value=$("#xianzkmc2").val();
    parent.document.getElementById("xianzkid2").value=$("#xianzkid2").val(); 
    parent.document.getElementById("xianzkmc3").value=$("#xianzkmc3").val();
    parent.document.getElementById("xianzkid3").value=$("#xianzkid3").val(); 
    parent.document.getElementById("xianzkmc4").value=$("#xianzkmc4").val();
    parent.document.getElementById("xianzkid4").value=$("#xianzkid4").val();    
    window.close();
}

    function load(){
    var parent=window.dialogArguments;
    var fazmc =parent.document.getElementById("fazmc").value;
    var fazbm =parent.document.getElementById("fazbm").value;
    var xianzkmc1 =parent.document.getElementById("xianzkmc1").value;
    var xianzkid1 =parent.document.getElementById("xianzkid1").value;
    var xianzkmc2 =parent.document.getElementById("xianzkmc2").value;
    var xianzkid2 =parent.document.getElementById("xianzkid2").value;
    var xianzkmc3 =parent.document.getElementById("xianzkmc3").value;
    var xianzkid3 =parent.document.getElementById("xianzkid3").value;
    var xianzkmc4 =parent.document.getElementById("xianzkmc4").value;
    var xianzkid4 =parent.document.getElementById("xianzkid4").value;
    
    if(fazmc=="") return;
       //$("#fazid").append("<option value='"+fazbm+"' selected>"+fazmc+"</option>");
       $("#fazid").val(fazbm);
       $("#fazmc").val(fazmc);
    if(xianzkmc1!=""){
       $("#xianzkid1").append("<option value='"+xianzkid1+"' selected>"+xianzkmc1+"</option>");
       $("#xianzkid1").val(xianzkid1);
       $("#xianzkmc1").val(xianzkmc1);
    } 
    if(xianzkmc2!=""){
       $("#xianzkid2").append("<option value='"+xianzkid2+"' selected>"+xianzkmc2+"</option>");
       $("#xianzkid2").val(xianzkid2);
       $("#xianzkmc2").val(xianzkmc2);
    }  
    if(xianzkmc3!=""){
       $("#xianzkid3").append("<option value='"+xianzkid3+"' selected>"+xianzkmc3+"</option>");
       $("#xianzkid3").val(xianzkid3);
       $("#xianzkmc3").val(xianzkmc3);
    }
    if(xianzkmc4!=""){
       $("#xianzkid4").append("<option value='"+xianzkid4+"' selected>"+xianzkmc4+"</option>");
       $("#xianzkid4").val(xianzkid4);
       $("#xianzkmc4").val(xianzkmc4);
    }
    }
    
    //function changeTabForFaz(){
    //$( "#fazmc").val( $("#fazid").find("option:selected").text());
   //}
    
    function changeTabForXianzk(val){
      if('1'==val){
      $( "#xianzkmc1").val( $("#xianzkid1").find("option:selected").text());
      }else if('2'==val){
      $( "#xianzkmc2").val( $("#xianzkid2").find("option:selected").text());
      }else if('3'==val){
      $( "#xianzkmc3").val( $("#xianzkid3").find("option:selected").text());
      }else if('4'==val){
      $( "#xianzkmc4").val( $("#xianzkid4").find("option:selected").text());
      }
    }
    
    function loadFzData(){
         $( "#fazmc").autocomplete({
  			minLength:2,
  			source:function( request, response ) {  
                  $.ajax({  
                      url: "<s:url value="/"/>/common/loadFz2",  
                      dataType: "json",  
                      data: {  
                          q: request.term  
                      },  
                      success: function( data ) {  

                      
                          response( $.map( data, function( item ) {  
                              return {  
                                  label: item.label,  
                                  value: item.value  
                              }  
                          }));  
                         
                      }  
                  });  
              },			
              select: function( event, ui ) {
  				$( "#fazmc").val( ui.item.label );							
  				$( "#fazid").val( ui.item.value );						
  				return false;

  			}
  		});
      }
    </script>

  </head>
  
  <body>
    <table cellpadding="0" cellspacing="0" class="content">
	<tr>
	<td>发站：</td>
	<td algin="left">
	<!--  <div class="select"><div>
	   <select id="fazid" style="width:180px" onchange="changeTabForFaz()">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="fz" items="${fzList}">
                   <option value="${fz.sysid}">
                   ${fz.mingch}
                   </option>
                   </c:forEach>
       </select>	
	</div></div>-->
	<input type="hidden" id="fazid">
	<input id="fazmc" name="fazmc" type="text"  title="请录入至少两个汉字关键字选择发站"/>
	</td>
	</tr>
	<td>限制口1：</td>
	<td algin="left">
	<div class="select"><div>
	   <select id="xianzkid1" style="width:180px" onchange="changeTabForXianzk('1')">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="xzk" items="${xzkList}">
                   <option value="${xzk.xianzkid}">
                   ${xzk.xianzkmc}
                   </option>
                   </c:forEach>
       </select>	
	</div></div>
	<input type="hidden" id="xianzkmc1">
	</td>
	</tr>
	<td>限制口2：</td>
	<td algin="left">
	<div class="select"><div>
	   <select id="xianzkid2" style="width:180px" onchange="changeTabForXianzk('2')">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="xzk" items="${xzkList}">
                   <option value="${xzk.xianzkid}">
                   ${xzk.xianzkmc}
                   </option>
                   </c:forEach>
       </select>	
	</div></div>
	<input type="hidden" id="xianzkmc2">
	</td>
	</tr>
	<td>限制口3：</td>
	<td algin="left">
	<div class="select"><div>
	   <select id="xianzkid3" style="width:180px" onchange="changeTabForXianzk('3')">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="xzk" items="${xzkList}">
                   <option value="${xzk.xianzkid}">
                   ${xzk.xianzkmc}
                   </option>
                   </c:forEach>
       </select>	
	</div></div>
	<input type="hidden" id="xianzkmc3">
	</td>
	</tr>
	<td>限制口4：</td>
	<td algin="left">
	<div class="select"><div>
	   <select id="xianzkid4" style="width:180px" onchange="changeTabForXianzk('4')">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="xzk" items="${xzkList}">
                   <option value="${xzk.xianzkid}">
                   ${xzk.xianzkmc}
                   </option>
                   </c:forEach>
       </select>	
	</div></div>
	<input type="hidden" id="xianzkmc4">
	</td>
	</tr>
	<tr>
		    <td>    
		    &nbsp;
		    </td>		    
            <td align="right"> 
            <input id="but1" type="button" name="" value="确认" onclick="save();"/>&nbsp;&nbsp;           
		    <input id="but2" type="button" name="" value="关闭" onclick="window.close();"/>
            </td>           
      </tr>
      <tr>
        <td colspan="2">
        <br>
               <span style="color: red;vertical-align:middle;">特别说明：近期由于最新IE11升级更新包（KB3008923）会导致发站、到站、品种质量指标等弹出窗口无法点击返回，解决办法：
请即时升级最新的补丁包（<a href="http://support.microsoft.com/kb/3025390">点击下载KB3025390</a> ）。
               </span>
        </td>
      </tr>
	</table>	
	
  </body>
</html>
